package com.example.superoa.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.example.superoa.model.service.BecomeService;
import com.example.superoa.model.vo.BecomeVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Controller
public class BecomeWrokerController {
	@Autowired
	private BecomeService becomeService;
	
	//查询转正数据
	@RequestMapping("become-list")
	@ResponseBody
	public Map<String,Object> selectbecome(int page,int rows){
		Map<String,Object> map = new HashMap<>();
		//先分页
		Page<Object> pg = PageHelper.startPage(page, rows);
		
		List<BecomeVo> i=becomeService.selectbecome();
		//总记录
		map.put("total", pg.getTotal());
		//页内容
		map.put("rows", i);
		return map;
	}
	//申请转正
	@PostMapping("become-states")
	@ResponseBody
	public void becomestate(String bwr_state,int bwr_id) {
		becomeService.becomestate("已转正", bwr_id);
	}
	//根据id查询转正信息
	@RequestMapping("become-id")
	@ResponseBody
	public BecomeVo selectId(int bwr_id,Model model) {
		return becomeService.selectId(bwr_id);
	}
	//查询结果
	@RequestMapping("become-jieguo")
	@ResponseBody
	public List<BecomeVo> selectjieguo(){
		return becomeService.selectjieguo();
	}
}
